home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / sound / sounddriver.h < prev    next >
Text File  |  1993-03-18  |  5KB  |  129 lines

  1. /*
  2.  *    sounddriver.h - functional sound/dsp driver interface.
  3.  *    Copyright 1988-90 NeXT, Inc.
  4.  *
  5.  */
  6.  
  7. #import <mach/mach.h>
  8. #import <mach/mach_init.h>
  9. #import <mach/message.h>
  10. #import <bsd/sys/types.h>
  11.  
  12. /*
  13.  * Valid sources and destination codes for stream setup
  14.  */
  15.  
  16. #define SNDDRIVER_STREAM_FROM_SNDIN            (1)
  17. #define SNDDRIVER_STREAM_TO_SNDOUT_22            (2)
  18. #define SNDDRIVER_STREAM_TO_SNDOUT_44            (3)
  19. #define SNDDRIVER_STREAM_FROM_DSP            (4)
  20. #define SNDDRIVER_STREAM_TO_DSP                (5)
  21. #define SNDDRIVER_STREAM_SNDIN_TO_DSP            (6)
  22. #define SNDDRIVER_STREAM_DSP_TO_SNDOUT_22        (7)
  23. #define SNDDRIVER_STREAM_DSP_TO_SNDOUT_44        (8)
  24. #define SNDDRIVER_STREAM_FROM_SNDIN_THROUGH_DSP        (9)
  25. #define SNDDRIVER_STREAM_THROUGH_DSP_TO_SNDOUT_22    (10)
  26. #define SNDDRIVER_STREAM_THROUGH_DSP_TO_SNDOUT_44    (11)
  27. /* New for 2.0 */
  28. #define SNDDRIVER_DMA_STREAM_TO_DSP            (12)
  29. #define SNDDRIVER_DMA_STREAM_FROM_DSP            (13)
  30. #define SNDDRIVER_DMA_STREAM_THROUGH_DSP_TO_SNDOUT_22    (14)
  31. #define SNDDRIVER_DMA_STREAM_THROUGH_DSP_TO_SNDOUT_44    (15)
  32. /* Reserved for private sound library use */
  33. #define SNDDRIVER_STREAM_RESERVED_1            (16)
  34. #define SNDDRIVER_STREAM_RESERVED_2            (17)
  35.  
  36. /*
  37.  * Protocol options for the dsp (subset of <nextdev/snd_msgs.h> protocols)
  38.  */
  39. #define SNDDRIVER_DSP_PROTO_DSPERR    0x1    // DSP error messages enabled
  40. #define SNDDRIVER_DSP_PROTO_C_DMA    0x2    // Complex DMA mode
  41. #define SNDDRIVER_DSP_PROTO_S_DMA    0x4    // Simple DMA mode
  42. /* New for 2.0 */
  43. #define SNDDRIVER_DSP_PROTO_HFABORT    0x80    // Enable DSP abort on HF2&HF3
  44. #define SNDDRIVER_DSP_PROTO_DSPMSG    0x100    // DSP messages enabled
  45. #define SNDDRIVER_DSP_PROTO_RAW     0x200    // Enable raw DSP mode
  46.  
  47. /*
  48.  * DSP Host Commands used with protocol SNDDRIVER_DSP_PROTO_C_DMA.
  49.  * See on-line programming examples for usage.
  50.  */
  51. #define SNDDRIVER_DSP_HC_HOST_RD    (0x24>>1)     // Host Read Done
  52. #define SNDDRIVER_DSP_HC_HOST_WD    (0x28>>1)    // Host Write Done
  53. #define SNDDRIVER_DSP_HC_SYS_CALL    (0x2C>>1)    // System Call
  54.  
  55. /*
  56.  * Control codes for streams
  57.  */
  58. #define SNDDRIVER_AWAIT_STREAM        (0x1)
  59. #define SNDDRIVER_ABORT_STREAM        (0x2)
  60. #define SNDDRIVER_PAUSE_STREAM        (0x4)
  61. #define SNDDRIVER_RESUME_STREAM        (0x8)
  62.  
  63. /*
  64.  * Driver message priorities
  65.  */
  66. #define SNDDRIVER_LOW_PRIORITY        (2)
  67. #define SNDDRIVER_MED_PRIORITY        (1)
  68. #define SNDDRIVER_HIGH_PRIORITY        (0)
  69.  
  70. /*
  71.  * DSP Host Interface Bits
  72.  */
  73. #define SNDDRIVER_ICR_INIT      (0x80000000)    // settable
  74. #define SNDDRIVER_ICR_HM1       (0x40000000)    // settable mode bit
  75. #define SNDDRIVER_ICR_HM0       (0x20000000)    // settable mode bit
  76. #define SNDDRIVER_ICR_HF1       (0x10000000)    // settable host flag
  77. #define SNDDRIVER_ICR_HF0       (0x08000000)    // settable host flag
  78. #define SNDDRIVER_ICR_TREQ      (0x02000000)    // read-only, set by protocol
  79. #define SNDDRIVER_ICR_RREQ      (0x01000000)    // read-only, set by protocol
  80.  
  81. #define SNDDRIVER_CVR_HC        (0x00800000)    // read-only, set by host cmd
  82. #define SNDDRIVER_CVR_HV_MASK   (0x001F0000)    // read-only, set by host cmd
  83.  
  84. #define SNDDRIVER_ISR_HREQ      (0x00008000)    // readable host request flag
  85. #define SNDDRIVER_ISR_DMA       (0x00004000)    // readable dma-mode flag
  86. #define SNDDRIVER_ISR_HF3       (0x00001000)    // readable host flag
  87. #define SNDDRIVER_ISR_HF2       (0x00000800)    // readable host flag
  88. #define SNDDRIVER_ISR_TRDY      (0x00000400)    // readable status bit
  89. #define SNDDRIVER_ISR_TXDE      (0x00000200)    // readable status bit
  90. #define SNDDRIVER_ISR_RXDF      (0x00000100)    // readable status bit
  91.  
  92.  
  93. #include "snddriver_client.h"
  94.  
  95. /*
  96.  * Asynchronous return message parsing and callout (the reply server).
  97.  *
  98.  * The snddriver_reply_server implementation takes a pointer to a message 
  99.  * and a pointer to a structure containing the dispatch functions for
  100.  * each type of message. It parses the message and calls the
  101.  * appropriate procedure, and handles the reply message (if any).
  102.  */
  103.  
  104. typedef void (*sndreply_tagged_t)(void *arg, int tag);
  105. typedef void (*sndreply_recorded_data_t)(void *arg, int tag, 
  106.                      void *data, int size);
  107. typedef void (*sndreply_dsp_cond_true_t)(void *arg, u_int mask, 
  108.                      u_int flags, u_int regs);
  109. typedef void (*sndreply_dsp_msg_t)(void *arg, int *data, int size);
  110.  
  111. typedef struct snddriver_handlers {
  112.     void *            arg;
  113.     int                timeout;
  114.     sndreply_tagged_t        started;
  115.     sndreply_tagged_t        completed;
  116.     sndreply_tagged_t        aborted;
  117.     sndreply_tagged_t        paused;
  118.     sndreply_tagged_t        resumed;
  119.     sndreply_tagged_t        overflow;
  120.     sndreply_recorded_data_t    recorded_data;
  121.     sndreply_dsp_cond_true_t    condition_true;
  122.     sndreply_dsp_msg_t        dsp_message;
  123.     sndreply_dsp_msg_t        dsp_error;
  124.  } snddriver_handlers_t;
  125.  
  126. kern_return_t snddriver_reply_handler(
  127.     msg_header_t        *msg,        // message to parse
  128.     snddriver_handlers_t    *handlers);    // table of callout procs
  129.